package com.cn.jx.message.service.Impl;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import com.cn.jx.message.entity.MessageEntity;
import com.cn.jx.message.service.IMessageMongoService;
import com.jx.enumType.MessageTypeEnum;
import com.jx.util.Utility;

@Service("messageMongoService") 
public class MessageMongoServiceImpl implements IMessageMongoService {

	@Autowired
    private MongoTemplate mongoTemplate;
	
	@Override
	public void sendAllMsgByOrg(String sender, Set<String> orgs, String title, String content, String operator) {
		if(orgs!=null && orgs.size()>0){
			MessageEntity op=new MessageEntity();
			op.setSender(sender);
			op.setTitle(title);
			op.setContent(content);
			op.setOperator(operator);
			op.setOperatTime(new Date());
			op.setMsgType(MessageTypeEnum.ALL.getCode());
			op.setOrgs(orgs);
			op.setSendSuccess(0);
			op.setRead(0);
			op.setSynchFlag(0);
			mongoTemplate.save(op);
		}
	}

	@Override
	public void sendAllMsgByOrgSign(String sender, String org, String title, String content, String operator) {
		if(Utility.isNotBlank(org)){
			Set<String> orgs=new HashSet<String>();
			orgs.add(org);
			sendAllMsgByOrg(sender,orgs,title,content,operator);
		}
	}

	@Override
	public void sendAllMsgByUser(String sender, Set<String> receivers, String title, String content, String operator) {
		
	}

	@Override
	public void sendAllMsgByUserSign(String sender, String receivers, String title, String content, String operator) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendEmailMsgByOrg(String sender, Set<String> orgs, String title, String content, String operator) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendEmailMsgByOrgSign(String sender, String orgs, String title, String content, String operator) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendEmailMsgByUser(String sender, Set<String> receivers, String title, String content,
			String operator) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendEmailMsgByUserSign(String sender, String receivers, String title, String content, String operator) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendOnlyMsgByOrg(String sender, Set<String> orgs, String title, String content, String operator) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendOnlyMsgByUser(String sender, Set<String> receivers, String title, String content,
			String operator) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendOnlyMsgByOrgSign(String sender, String orgs, String title, String content, String operator) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendOnlyMsgByUserSign(String sender, String receivers, String title, String content, String operator) {
		// TODO Auto-generated method stub
		
	}

}
